//
//  AEPointsAcquireViewController.m
//  AESOLAR_IOS
//
//  Created by Bin Tang on 2024/10/15.
//  Copyright © 2024 Mr.Wang. All rights reserved.
//

#import "AEPointsAcquireViewController.h"
#import "AEPointsAcquireViewModel.h"
#import "AEPointsAcquireNavView.h"
#import "AEPointsAcquireTopView.h"
#import "AEPointsAcquireMainView.h"

@interface AEPointsAcquireViewController ()

@property (nonatomic, strong) AEPointsAcquireViewModel *viewModel;

@property (nonatomic, strong) AEPointsAcquireNavView *navView;

@property (nonatomic, strong) AEPointsAcquireTopView *topView;

@property (nonatomic, strong) AEPointsAcquireMainView *mainView;

@end

@implementation AEPointsAcquireViewController

- (void)dealloc {
    debugMethod();
}

- (void)initWithVar {
    [super initWithVar];
    
}

- (void)initWithViewModel {
    _viewModel = [AEPointsAcquireViewModel new];
    [_viewModel setupData];
    
}

- (void)initWithNavBar {
    [super initWithNavBar];
    
}

- (void)initWithSubView {
    [super initWithSubView];
    
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F6F8F8"];
    
    self.baseTableView.hidden = YES;
    
    [self initWithRootContent:NO];
    self.rootContent.top = 0;
    self.rootContent.height = kScreenH;
    self.rootContent.backgroundColor = [UIColor colorWithHexString:@"#F6F8F8"];
    
    [self initWithNavView];
    
    [self initWithTopView];
    
    [self initWithmainView];
    
    if (self.rootContent.height < self.mainView.bottom) {
        self.rootContent.contentSize = CGSizeMake(kScreenW, self.mainView.bottom + 20);
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}


- (void)initWithNavView {
    if (!_navView) {
        CGRect frame = CGRectMake(0, 0, kScreenW, NAVBAR_HEIGHT_STATUS);
        _navView = [[AEPointsAcquireNavView alloc] initWithFrame:frame];
        [self.view addSubview:_navView];
        @weakify(self);
        _navView.touchBackBlock = ^{
            @strongify(self);
            [self clickedBack:nil];
        };
    }
}

- (void)initWithTopView {
    if (!_topView) {
        CGRect frame = CGRectMake(0, 0, kScreenW, kAEPointsAcquireTopViewHeight);
        if (IPHONEX_TOP_SPACE == 0) {
            frame.size.height = frame.size.height - 24;
        }
        _topView = [[AEPointsAcquireTopView alloc] initWithFrame:frame];
        [self.rootContent addSubview:_topView];
        @weakify(self);
        _topView.touchSignInBlock = ^{
            @strongify(self);
            [self actionWithSignIn];
        };
    }
    [self.topView updateWithViewData:self.viewModel];
}

- (void)initWithmainView {
    if (!_mainView) {
        CGRect frame = CGRectMake(15, self.topView.bottom + 12, kScreenW - 30, 50 + kAEPointsAcquireMainSingleViewHeight * self.viewModel.dataList.count);
        _mainView = [[AEPointsAcquireMainView alloc] initWithFrame:frame];
        [self.rootContent addSubview:_mainView];
        @weakify(self);
        _mainView.touchGoFinishBlock = ^(TYZCommonCellModel * _Nonnull model) {
            @strongify(self);
            [self actionWithGoFinish:model];
        };
    }
    [self.mainView updateWithViewData:self.viewModel];
}

/// 点击签到
- (void)actionWithSignIn {
    [SVProgressHUD showInfoWithStatus:@"点击签到"];
}

/// 去完成
/// - Parameter model: model description
- (void)actionWithGoFinish:(TYZCommonCellModel *)model {
    [SVProgressHUD showInfoWithStatus:@"去完成"];
}

@end
